package com.metroinfo.parser;

import java.nio.ByteBuffer;

import com.metroinfo.parser.data.GeneralRequest;

public class CommandParser {
	
	ParseInterface parser = null;
	
	public GeneralRequest getData (ByteBuffer cb)
	{
		if (cb.limit() == 0 ) return null;
		
		GeneralRequest retVal = new GeneralRequest();
		ParseInterface worker = null;
		
		switch (cb.get(0)){
		case(GeneralSettings.CT_SEND_DATA):
			retVal.setReqType(GeneralSettings.CT_SEND_DATA);
			worker = ParserTypeFactory.getParser(GeneralSettings.CT_SEND_DATA);
			retVal.setKey(worker.getKey(cb));
			retVal.setData(worker.getParsed(cb));
			break;
		default: break;
			
		}
		
		return retVal;
	}
}
